# coding=utf-8
import re

reader = open("mysqlddl.txt", "r")
writer = open("odpsddl.txt", "w")

lines = reader.readlines()
tmp1 = 0
tmp2 = 0
for line in lines:
    lower = line.lower()
    if "decimal" in lower:
        tmp1 = lower.split("(")[1].split(")")[0].split(",")[0]
        tmp2 = lower.split("(")[1].split(")")[0].split(",")[1]
    # 正则匹配去掉括号里面的数字，再把括号去掉
    flag = re.sub(r"([\d])", "", lower.strip()).replace("()", "")

    result = flag. \
        replace("varchar", "string") \
        .replace("mediumint", "int") \
        .replace(",", "{},{}".format(tmp1, tmp2)) \
        .replace("char", "string")\
        .replace("0,0",",")
    writer.writelines(result+"\n")
reader.close()
writer.close()